
import java.awt.*;
import javax.swing.*;

public class Question1 {
    public static void main(String[] args) {
        JFrame frame = new JFrame("题1");    //创建Frame窗口
        frame.setLayout(new BorderLayout());
        JPanel panel = new JPanel();    //创建面板
        JLabel label1 = new JLabel("性别：");
        JRadioButton rb1 = new JRadioButton("男");    //创建JRadioButton对象
        JRadioButton rb2 = new JRadioButton("女");    //创建JRadioButton对象
        label1.setFont(new Font("楷体", Font.BOLD, 16));    //修改字体样式
        ButtonGroup group = new ButtonGroup();
        //添加JRadioButton到ButtonGroup中
        group.add(rb1);
        group.add(rb2);
        panel.add(label1);
        panel.add(rb1);
        panel.add(rb2);
        frame.add(panel, BorderLayout.NORTH);//让panel在上方

        JPanel panel2 = new JPanel();    //创建面板
        JLabel label2 = new JLabel("爱好：");
        label2.setFont(new Font("楷体", Font.BOLD, 16));    //修改字体样式
        JCheckBox checkBox1 = new JCheckBox("读书");    //创建指定文本的复选框
        JCheckBox checkBox2 = new JCheckBox("体育");    //创建指定文本的复选框
        JCheckBox checkBox3 = new JCheckBox("音乐");    //创建指定文本的复选框
        panel2.add(label2);
        panel2.add(checkBox1);
        panel2.add(checkBox2);
        panel2.add(checkBox3);
        frame.add(panel2, BorderLayout.SOUTH);//让panel在下方

        frame.setBounds(300, 200, 400, 400);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
